Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quantization Support #46

Merged
merged 7 commits into from
Jan 5, 2024

Conversation

saileshd1402
Copy link
Contributor

@saileshd1402 saileshd1402 commented Jan 3, 2024

Changes:

  • Added bitsandbytes quantization of precision 4 and 8 bits support. (number of bits can be passed though '-q' argument in llm/run.sh)

@@ -365,6 +369,8 @@ def execute(params: argparse.Namespace) -> None:
mount_path = params.mount_path
model_timeout = params.model_timeout

quantize_bits = params.quantize_bits
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

white space on top

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@gavrissh gavrissh self-requested a review January 4, 2024 09:58
llm/handler.py Outdated
@@ -112,8 +112,29 @@ def initialize(self, context: ts.context.Context):
self.tokenizer.padding_side = "left"
logger.info("Tokenizer loaded successfully")

quantize_bits = self.get_env_value("NAI_QUANTIZATION")
quantize_bits = int(quantize_bits) if quantize_bits else quantize_bits
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep it simple here. you are doing the check, just to type cast

if self.get_env_value("NAI_QUANTIZATION"):
   quantize_bits = int(self.get_env_value("NAI_QUANTIZATION"))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed as suggested

@@ -382,6 +387,15 @@ def execute(params: argparse.Namespace) -> None:
model_info["repo_id"] = model_params["repo_id"]
model_info["repo_version"] = check_if_valid_version(model_info, mount_path)

if quantize_bits and int(quantize_bits) not in [4, 8]:
print("## Quantization precision bits should be either 4 or 8")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There can be question, why it's not taking 16 as well. Add a text,

print("## Quantization precision bits should be either 4 or 8. Default precision used is 16")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the mentioned message

@gavrissh gavrissh self-requested a review January 5, 2024 06:07
@johnugeorge johnugeorge merged commit d905b6f into nutanix:main Jan 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants